<template>
	<view class="poster-wapper">
		<image 
		:src="url" 
		mode="aspectFit" 
		class="poster" 
		<!-- #ifndef H5 -->
		@longtap="downloadImg()"
		<!-- #endif -->
		></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url:"",
			}
		},
		methods: {
			// 下载图片
			downloadImg(){
				let me=this;
				uni.showActionSheet({
					itemList:["下载","返回"],
					success(res) {
						if(res.tapIndex==0){
							uni.showLoading({
								mask:true
							})
							uni.downloadFile({
								url:me.url,
								success(resovle) {
									uni.saveImageToPhotosAlbum({
										filePath:resovle.tempFilePath,
										success() {
											uni.showToast({
												title:"保存成功",
												duration:2000
											})
										},
										complete() {
											uni.hideLoading()
										}
									})
								}
							})
						}
					}
				})
			},
			getMovieInfo(id){
				uni.request({
					url:this.root+'/api/getMovieInfo/'+id,
					success:(res)=>{
						console.log(this.root+'/api/getMovieInfo/'+id)
						// debugger
						if(res.data.err==0){
							this.url=res.data.data[0].poster_url
						}
					}
				})
			}
		},
		onLoad(query) {
			uni.setNavigationBarColor({
				backgroundColor:"#000000",
				frontColor:"#FFFFFF"
			})
			console.log(query)
			this.getMovieInfo(query.id)
		}
	}
</script>

<style scoped>
.poster-wapper{
	width: 100%;
	height: 100%;
	background-color: #000;
	position: absolute;
	display: flex;
	align-items: center;
}
.poster{
	background-color: #000;
	width: 100%;
	height: 100%;
}
</style>
